package com.kaluli.config;

import java.util.Properties;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;

@Configuration
/*@ComponentScan(basePackages = "com.kaluli.fire.detect.service")*/
@ComponentScan(basePackages = { "com.kaluli.project.service","com.kaluli.system.listener" } )
@PropertySource({ "classpath:file.properties" })
@EnableScheduling
public class ServiceConfig {

	@Autowired
	private Environment env;

/*	@Bean
	public ProjectFlowService projectFlowService(NextStatus[] statuses){
		return new ProjectFlowService(statuses);
	}*/
	@Bean
	public SimpleMappingExceptionResolver getSimpleMappingExceptionResolver(){
		SimpleMappingExceptionResolver exceptionResolver= new SimpleMappingExceptionResolver();
//		exceptionResolver.setDefaultErrorView("/error");
//		exceptionResolver.setDefaultStatusCode(500);
//		Properties properties1 = new Properties();
//		properties1.put("/error", "404");
//		exceptionResolver.setStatusCodes(properties1);
		Properties properties = new Properties();
		properties.put("java.lang.Exception", "/error");
		exceptionResolver.setExceptionMappings(properties);
		return exceptionResolver;
	}
	
//	@Bean
//	public Properties getFtpConfig(){
//		Properties prop = new Properties();
//		prop.put("ftp.url", env.getProperty("ftp.url"));
//		prop.put("ftp.username", env.getProperty("ftp.username"));
//		prop.put("ftp.password", env.getProperty("ftp.password"));
//		prop.put("ftp.port",env.getProperty("ftp.port"));
//		prop.put("ftp.order.in",env.getProperty("ftp.order.in"));
//		prop.put("ftp.order.out", env.getProperty("ftp.order.out"));
//		prop.put("ftp.local", env.getProperty("ftp.local"));
//		return prop;
//	}
}
